package com.gs.wzmanager.controller;

import com.gs.wzmanager.entity.ForeThreshold;
import com.gs.wzmanager.service.ForeThresholdService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping(value = "/threshold")
public class ThresholdController {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    ForeThresholdService service;

    @RequestMapping(value = "listView")
    public String view(){
        return "threshold/list";
    }

    /*
    查询所有预报阈值信息
     */
    @RequestMapping(value = "queryAll")
    @ResponseBody
    public List<ForeThreshold> queryAll(String stationName) {
        return service.queryForeThresholdByStationName(stationName);
    }


    @RequestMapping(value = "queryTypes")
    @ResponseBody
    public List queryThresholdType() {
        return service.queryThreshold();
    }
    /*
    更新预报阈值信息
     */
    @RequestMapping(value = "update", method = RequestMethod.POST)
    public ResponseEntity updateDisasterForecast(@RequestBody ForeThreshold foreThreshold) {
        logger.info("updateDisasterForecast->{}", foreThreshold);
        return service.update(foreThreshold);
    }

    @RequestMapping(value = "add", method = RequestMethod.POST)
    public ResponseEntity addDisasterForecast(@RequestBody ForeThreshold foreThreshold) {
        logger.info("addDisasterForecast->{}", foreThreshold);
        return service.add(foreThreshold);
    }

    @RequestMapping(value = "delete")
    public ResponseEntity deleteDisasterForecast(Integer id) {
        return service.delete(id);
    }




}
